<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding">
        <div class=" rc-pannel ">
            <div class=" rc-pannel-header">
                <div class="rc-flex layui-form toolbar rc-flex-justify-between">
                    <div class=" rc-flex rc-flex-vertical-center ">

                    </div>
                    <div>
                        <a href="/admin/cnf/UserModel/addInfoTable" class="layui-btn layui-btn-primary layui-btn-sm"><i class="iconfont">&#xe60e;</i> 添加信息资料表</a>

                    </div>
                </div>


            </div>


            <div class="rc-pannel-body layui-form rc-pagepadding">

                <table class="layui-table">
                    <colgroup>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col style="width: 240px;">

                    </colgroup>
                    <thead>
                        <tr>
                            <th>名称</th>
                            <th>表名</th>
                            <th>多行记录？</th>
                            <th>完善资料？</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        foreach ($tables as $table) {
                        ?>
                            <tr>
                                <td><?php echo $table['title'] ?></td>
                                <td><?php echo $table['name'] ?></td>

                                <td class="<?php echo $table['multiline'] == 1 ? 'rc-text-color-success' : '' ?>"><?php echo $table['multiline'] == 1 ? '是' : '否' ?></td>
                                <td class="<?php echo $table['improve'] == 1 ? 'rc-text-color-success' : '' ?>"><?php echo $table['improve'] == 1 ? '是' : '否' ?></td>

                                <td>
                                    <div class="rc-opbar">
                                        <a class="info managefield" tableid="<?php echo  $table['id']; ?>"><i class="iconfont">&#xe612;</i> 字段</a>
                                        <a class="info" href="/admin/cnf/UserModel/editInfoTable?tableid=<?php echo $table['id'] ?>"><i class="iconfont">&#xe606;</i> 编辑</a>
                                        <a class="error delete" tableid="<?php echo $table['id'] ?>"><i class="iconfont">&#xe636;</i> 删除 </a>
                                    </div>
                                </td>
                            </tr>
                        <?php
                        } ?>



                    </tbody>
                </table>



            </div>
        </div>
    </div>
</div>
<script>
    layui.use(function() {

        var layer = layui.layer;



        $(".managefield").click(function() {
            var tableid = $(this).attr('tableid');
            layer.open({
                type: 2, // page 层类型
                area: ['95%', '800px'],
                title: '字段管理',
                shade: 0.6, // 遮罩透明度
                shadeClose: false, // 点击遮罩区域，关闭弹层
                maxmin: true, // 允许全屏最小化
                anim: 0, // 0-6 的动画形式，-1 不开启
                content: '/admin/cnf/UserModel/infoFieldManage?tableid=' + tableid
            });
        });

        $('.delete').click(function() {
            var tableid = $(this).attr('tableid');
            layer.confirm('确定要删除么？', {
                icon: 3
            }, function() {
                $.ajax({
                    url: '/admin/cnf/UserModel/delInfoTable?tableid=' + tableid, //请求路径
                    type: "POST", //请求方式
                    success: function(data) {
                        if (data.code == 0) {
                            window.location.reload();
                        } else {
                            toastr_error(data.message);
                        }
                        layer.closeAll();
                    },
                    error: function() {
                        layer.closeAll();
                    },

                });


            }, function() {



            });

        })


    });
</script>